package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
*功能：
 作者：chenhao
*日期： 2024/11/19 下午3:31
*/
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result error(Exception e){

        e.printStackTrace();
        return Result.fail();
    }
    @ExceptionHandler(LeaseException.class)
    public Result error(LeaseException e){
        e.printStackTrace();

        return Result.fail(e.getMessage(),e.getCode());
    }
}
